<?php

class Admin_Quotation extends Controller
{
	var $data=array();
	
	public function __construct()
	{
		parent::Controller();
        include("password_protect.php");
		$this->load->model('Admin_Quotation_Model');
		
		$this->data['warning']="";
		$this->data['other_comment']="";
		$this->data['shipdest_comment']="";
		$this->data['requester_name']="";
		$this->data['requesting_comp_name']="";
		$this->data['requesting_comp_name']="";
		$this->data['requester_phone']="";
		$this->data['designator_id']=-1;
		$this->data['designator_title']="";
		$this->data['your_number']="";
		$this->data['province_list']="";
		$this->data['city_list']="";

		$this->data['pickup_time']="";
		$this->data['pickup_time_period']="";
		$this->data['dock_closed_time']="";
		$this->data['dock_closed_time_period']="";
		
		$this->data['pickup_date']="";
		$this->data['pickup_contact_name']="";
		$this->data['pickup_address']="";
		$this->data['pickup_city']="";
		$this->data['pickup_province']="";
		$this->data['pickup_country']="";
		$this->data['pickup_p_code']="";
		$this->data['pickup_fax']="";
		$this->data['pickup_company_name']="";
		$this->data['pickup_phone_number']="";

		$this->data['destination_contact_name']="";
		$this->data['destination_address']="";
		$this->data['destination_p_code']="";
		$this->data['destination_city']="";
		$this->data['destination_province']="";
		$this->data['destination_country']="";
		$this->data['destination_fax']="";
		$this->data['destination_company_name']="";
		$this->data['destination_phone_number']="";
		
		$this->data['goods_description']="";
		$this->data['total_pieces']="";
		$this->data['total_weight']="";
		$this->data['hand_inst']="";
		$this->data['is_hazardous']=-1;

		$this->data['designator_id']=-1;
		
		// load 'url' helper
		$this->load->helper('url');

		// load 'form' helper
		$this->load->helper('form');

		// load 'validation' class
		$this->load->library('validation');
	}
	
	function index()
	{

		$this->load->view("admin_quotation",$this->data);
	}
	
	function read_quotation($id)
	{
		$quotation=$this->Admin_Quotation_Model->read_quotation($id);
	
		$this->data['requester_name']=$quotation->requester_name;
//		$this->data['requesting_comp_name']=$quotation->requesting_comp_name;
//		$this->data['your_number']=;
		$this->data['email']=$quotation->email;
		$this->data['requester_phone']=$quotation->phone;
		$this->data['designator_id']=$quotation->designation_id;
		$this->data['designator_title']=$this->Admin_Quotation_Model->get_designation_id($this->data['designator_id']);
		$this->data['pickup_date']=$quotation->pickup_date;
		$this->data['goods_description']=$quotation->goods_description;
		$this->data['other_comment']=$quotation->other_comment;
		$this->data['shipdest_comment']=$quotation->shipping_desctination_comment;
		$this->data['hand_inst']=$quotation->handling_instruction;
		$this->data['pickup_date']=$quotation->pickup_date;
		$this->data['pickup_time']=$quotation->pickup_time;
		$this->data['dock_closed_time']=$quotation->dock_closing_time;
		$this->data['total_weight']=$quotation->total_weight;
		$this->data['is_hazardous']=$quotation->is_hazardous;
		$this->data['total_pieces']=$quotation->pieces;
		
		$address=$this->Admin_Quotation_Model->read_address($quotation->origin_address_id);
		$city=$this->Admin_Quotation_Model->get_city($address->city_id);
		$this->data['pickup_city']=$city->city_name;

		$province=$this->Admin_Quotation_Model->get_province($address->province_id);
		$this->data['pickup_province']=$province->state_province_name;
		$this->data['pickup_contact_name']=$address->name;
		$this->data['pickup_country']=$province->country_name;
		$this->data['pickup_address']=$address->street;
		$this->data['pickup_p_code']=$address->postal_code;
		$this->data['pickup_fax']=$address->fax;
		$this->data['pickup_company_name']=$address->company_name;
		$this->data['pickup_phone_number']=$address->phone;

		$address=$this->Admin_Quotation_Model->read_address($quotation->destination_address_id);
		$city=$this->Admin_Quotation_Model->get_city($address->city_id);
		$this->data['destination_city']=$city->city_name;

		$province=$this->Admin_Quotation_Model->get_province($address->province_id);
		$this->data['destination_country']=$province->country_name;
		$this->data['destination_province']=$province->state_province_name;
		$this->data['destination_contact_name']=$address->name;;
		$this->data['destination_address']=$address->street;
		$this->data['destination_p_code']=$address->postal_code;
		$this->data['destination_fax']=$address->fax;
		$this->data['destination_company_name']=$address->company_name;
		$this->data['destination_phone_number']=$address->phone;
		
		$this->load->view("admin_quotation",$this->data);
	}
}
?>